/*
 * FileBufferedReader.java
 *
 * Created on 06 October 2006, 20:05
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package hubsniffer.sghdc.file.io;

import hubsniffer.sghdc.FileList;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.text.ParseException;

/**
 *
 * @author root
 */
public class FileBufferedReader extends BufferedReader{
    
    /** Creates a new instance of FileBufferedReader */
    public FileBufferedReader(InputStreamReader in) {
        super(in);
    }
    
    public libjdc.dc.filelist.File readFile() throws IOException{
        String answer = super.readLine();
        Object[] obj;
        try {
            obj = FileList.FILE_PARSER.parse(answer);
            
            
            libjdc.dc.filelist.File file = new libjdc.dc.filelist.File(obj[0].toString(),obj[1].toString(),obj[2].toString());
            file.setCount(new Integer(obj[3].toString()).intValue());
            return file;
        } catch (ParseException ex) {
            ex.printStackTrace();
            return null;
        }
    }
    
}
